#version 320 es
#ifdef GL_ES
	precision highp float;
#endif
out vec4 FragColor;
in float z;

struct Range {
	float zStart;
	float zEnd;
	float zCenter;
};
uniform Range range;

uniform vec4 color;

void main()
{
	float alpha;
	if (z > range.zCenter)// lower part
		alpha = (range.zStart - z) / (range.zStart - range.zCenter);
	else// upper part
		alpha = 1.0 - (range.zCenter - z) / (range.zCenter - range.zEnd);
	FragColor = vec4(color.rgb, alpha * color.a);
}